﻿using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tpl.Domain.Entities;

namespace Tpl.Domain.Config
{
    public class RegistrationConfig : EntityTypeConfiguration<Registration, long>
    {
        public override void Configure(EntityTypeBuilder<Registration> builder)
        {
            base.Configure(builder);

            builder.Property(x => x.Id).ValueGeneratedOnAdd(); //设置book的id自增
            builder.HasOne(r => r.User).WithMany(x => x.RegHistory)
                .HasForeignKey(r =>r.UserId).IsRequired(false);//导航属性，本质就是创建外键，虽然查询很方便，生产中不建议使用！！！
        }

    }
}
